#!/bin/bash

ROOT_PATH=$(cd $(dirname $0) && pwd);

apt purge -y freeradius
apt autoremove -y

apt -y install freeradius


PASS=$(cat $ROOT_PATH/cfg/user.secret)


sudo sed -i 's/^[^#].*Cleartext-Password :=.*//' /etc/freeradius/3.0/mods-config/files/authorize

sudo sed -i '1i\dvn01	Cleartext-Password := \"'$PASS'\"' /etc/freeradius/3.0/mods-config/files/authorize
sudo sed -i '1i\dvv01	Cleartext-Password := \"'$PASS'\"' /etc/freeradius/3.0/mods-config/files/authorize
sudo sed -i '1i\trv01	Cleartext-Password := \"'$PASS'\"' /etc/freeradius/3.0/mods-config/files/authorize
sudo sed -i '1i\trn01	Cleartext-Password := \"'$PASS'\"' /etc/freeradius/3.0/mods-config/files/authorize
sudo sed -i '1i\trc01	Cleartext-Password := \"'$PASS'\"' /etc/freeradius/3.0/mods-config/files/authorize
sudo sed -i '1i\user	Cleartext-Password := \"'$PASS'\"' /etc/freeradius/3.0/mods-config/files/authorize
sudo sed -i '1i\prx-client	Cleartext-Password := \"'$PASS'\"' /etc/freeradius/3.0/mods-config/files/authorize
sudo sed -i '1i\prz-client	Cleartext-Password := \"'$PASS'\"' /etc/freeradius/3.0/mods-config/files/authorize


service freeradius restart

